﻿Public Class USUARIO
    Public Function Crypt(ByVal Text As String) As String
        Dim strTempChar As String
        For i = 1 To Len(Text)
            If Asc(Mid$(Text, i, 1)) < 128 Then
                strTempChar = Asc(Mid$(Text, i, 1)) + 128
            ElseIf Asc(Mid$(Text, i, 1)) > 128 Then
                strTempChar = Asc(Mid$(Text, i, 1)) - 128
            End If
            Mid$(Text, i, 1) = Chr(strTempChar)
        Next i
        Crypt = Text
    End Function
    Private Sub USUARIO_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'LOGINDataSet.LOGIN' table. You can move, or remove it, as needed.
        Me.LOGINTableAdapter.Fill(Me.LOGINDataSet.LOGIN)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.ShowDialog()
        ASSINATURATextBox.Text = OpenFileDialog1.FileName
    End Sub

    Private Sub PRIMEIRO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PRIMEIRO.Click
        LOGINBindingSource.MoveFirst()
    End Sub

    Private Sub VOLTAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VOLTAR.Click
        LOGINBindingSource.MovePrevious()
    End Sub

    Private Sub NOVO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NOVO.Click
        LOGINBindingSource.AddNew()
    End Sub

    Private Sub SALVAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SALVAR.Click
        If IDTextBox.Text < 0 Then
            SENHATextBox.Text = Crypt(SENHATextBox.Text)
        Else
            SENHATextBox.Text = SENHATextBox.Text
        End If
        Me.Validate()
        Me.LOGINBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.LOGINDataSet)
    End Sub

    Private Sub DELETAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DELETAR.Click
        Me.Validate()
        LOGINBindingSource.RemoveCurrent()
        LOGINTableAdapter.Update(LOGINDataSet.LOGIN)
    End Sub

    Private Sub FRENTE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FRENTE.Click
        LOGINBindingSource.MoveNext()
    End Sub

    Private Sub ULTIMO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ULTIMO.Click
        LOGINBindingSource.MoveLast()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.LOGINTableAdapter.Fill(Me.LOGINDataSet.LOGIN)
    End Sub
End Class